import request from '../utils/request'

/** 文章接口 */
// 分页
export function articlePageList (params) {
    return request({
        url: '/api/v1/article/pageList',
        method: 'get',
        params
    })
}

// 保存
export function articleSave (form) {
    return request({
        url: '/api/v1/article/save',
        method: 'post',
        data: {
            title: form.title,
            author: form.author,
            cover: form.cover,
            shortLine: form.shortLine,
            content: form.content,
            categoryId: form.categoryId,
            isCarousel: form.isCarousel,
            isRecommend: form.isRecommend,
            isOriginal: form.isOriginal,
            isTop: form.isTop,
            tagIds: form.tagIds
        }
    })
}

// 详情
export function articleDeletes (form) {
    return request({
        url: '/api/v1/article/deletes',
        method: 'post',
        data: form
    })
}

// 修改
export function articleUpdate (form) {
    return request({
        url: '/api/v1/article/update',
        method: 'post',
        data: {
            id: form.id,
            title: form.title,
            author: form.author,
            cover: form.cover,
            shortLine: form.shortLine,
            content: form.content,
            categoryId: form.categoryId,
            isCarousel: form.isCarousel,
            isRecommend: form.isRecommend,
            isTop: form.isTop,
            tagIds: form.tagIds
        }
    })
}

// 文章分类统计
export function articleEchartsArticleCategoryCountPie () {
    return request({
        url: '/api/v1/article/echartsArticleCategoryCountPie',
        method: 'get'
    })
}

// 排名前十统计
export function articleEchartsVisitRankBar () {
    return request({
        url: '/api/v1/article/echartsVisitRankBar',
        method: 'get'
    })
}

export function articleDetail (params) {
    return request({
        url: '/api/v1/article/detail',
        method: 'get',
        params: {
            id: params.id
        }
    })
}

/** 文章分类接口 */
// 分页
export function articleCategoryPageList (params) {
    return request({
        url: '/api/v1/article/category/pageList',
        method: 'get',
        params
    })
}

// 列表条件
export function articleCategoryQueryList (params) {
    return request({
        url: '/api/v1/article/category/queryList',
        method: 'get',
        params
    })
}

// 保存
export function articleCategorySave (parms) {
    return request({
        url: '/api/v1/article/category/save',
        method: 'post',
        data: {
            name: parms.name,
            enabled: parms.enabled
        }
    })
}

// 修改
export function articleCategoryUpdate (parms) {
    return request({
        url: '/api/v1/article/category/update',
        method: 'post',
        data: {
            id: parms.id,
            name: parms.name,
            enabled: parms.enabled
        }
    })
}

// 删除
export function articleCategoryDeletes (parms) {
    return request({
        url: '/api/v1/article/category/deletes',
        method: 'post',
        data: parms
    })
}

/** 文章标签接口 */
// 分页
export function articleTagPageList (params) {
    return request({
        url: '/api/v1/article/tag/pageList',
        method: 'get',
        params
    })
}

// 列表
export function articleTagList () {
    return request({
        url: '/api/v1/article/tag/tagList',
        method: 'get'
    })
}

// 保存
export function articleTagSave (parms) {
    return request({
        url: '/api/v1/article/tag/save',
        method: 'post',
        data: {
            name: parms.name,
            type: parms.type
        }
    })
}

// 修改
export function articleTagUpdate (parms) {
    return request({
        url: '/api/v1/article/tag/update',
        method: 'post',
        data: {
            id: parms.id,
            name: parms.name,
            type: parms.type
        }
    })
}

// 删除
export function articleTagDeletes (parms) {
    return request({
        url: '/api/v1/article/tag/deletes',
        method: 'post',
        data: parms
    })
}
